package com.ruoyi.suppliers_zlw.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.suppliers_zlw.domain.ZlwSuppliers;
import com.ruoyi.suppliers_zlw.service.IZlwSuppliersService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 供应商信息管理系统Controller
 * 
 * @author zlw
 * @date 2025-06-11
 */
@Controller
@RequestMapping("/suppliers_zlw/suppliers")
public class ZlwSuppliersController extends BaseController
{
    private String prefix = "suppliers_zlw/suppliers";

    @Autowired
    private IZlwSuppliersService zlwSuppliersService;

    @RequiresPermissions("suppliers_zlw:suppliers:view")
    @GetMapping()
    public String suppliers()
    {
        return prefix + "/suppliers";
    }

    /**
     * 查询供应商信息管理系统列表
     */
    @RequiresPermissions("suppliers_zlw:suppliers:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZlwSuppliers zlwSuppliers)
    {
        startPage();
        List<ZlwSuppliers> list = zlwSuppliersService.selectZlwSuppliersList(zlwSuppliers);
        return getDataTable(list);
    }

    /**
     * 导出供应商信息管理系统列表
     */
    @RequiresPermissions("suppliers_zlw:suppliers:export")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZlwSuppliers zlwSuppliers)
    {
        List<ZlwSuppliers> list = zlwSuppliersService.selectZlwSuppliersList(zlwSuppliers);
        ExcelUtil<ZlwSuppliers> util = new ExcelUtil<ZlwSuppliers>(ZlwSuppliers.class);
        return util.exportExcel(list, "供应商信息管理系统数据");
    }

    /**
     * 新增供应商信息管理系统
     */
    @RequiresPermissions("suppliers_zlw:suppliers:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存供应商信息管理系统
     */
    @RequiresPermissions("suppliers_zlw:suppliers:add")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZlwSuppliers zlwSuppliers)
    {
        return toAjax(zlwSuppliersService.insertZlwSuppliers(zlwSuppliers));
    }

    /**
     * 修改供应商信息管理系统
     */
    @RequiresPermissions("suppliers_zlw:suppliers:edit")
    @GetMapping("/edit/{supplierId}")
    public String edit(@PathVariable("supplierId") String supplierId, ModelMap mmap)
    {
        ZlwSuppliers zlwSuppliers = zlwSuppliersService.selectZlwSuppliersBySupplierId(supplierId);
        mmap.put("zlwSuppliers", zlwSuppliers);
        return prefix + "/edit";
    }

    /**
     * 修改保存供应商信息管理系统
     */
    @RequiresPermissions("suppliers_zlw:suppliers:edit")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZlwSuppliers zlwSuppliers)
    {
        return toAjax(zlwSuppliersService.updateZlwSuppliers(zlwSuppliers));
    }

    /**
     * 删除供应商信息管理系统
     */
    @RequiresPermissions("suppliers_zlw:suppliers:remove")
    @Log(title = "供应商信息管理系统", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zlwSuppliersService.deleteZlwSuppliersBySupplierIds(ids));
    }
}
